package com.cowcode.controller;

import com.cowcode.biz.CollectBiz;
import com.cowcode.biz.UserBiz;
import com.cowcode.entity.User;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

/**
 * User: ljy
 * Date: 2021/7/4
 * Time: 23:30
 */
@Controller
@RequestMapping("user/")
public class UserController {
    @Resource
    private UserBiz userBiz;
    @Resource
    private CollectBiz collectBiz;

    @RequestMapping("deletecollect/{qid}")
    public String deletecollect(@PathVariable("qid") Integer qid, Model model, HttpSession session){
        User user = (User) session.getAttribute("user");
        if (collectBiz.deleteCollect(user.getUid(),qid)) {
            model.addAttribute("msg","取消收藏成功");
        } else {
            model.addAttribute("msg","取消收藏失败");
        }
        return "redirect:/jump/touser";
    }
}
